namespace CSharpPro._1009;

public class Demo
{
    public void TestPrint()
    {
        for (int num = 100; num < 1000; num++)
        {
            int hundreds = num / 100;
            int tens = (num / 10) % 10;
            int units = num % 10;
            if (hundreds * hundreds * hundreds + tens * tens * tens + units * units * units == num)
            {
                Console.WriteLine(num);
            }
        }
    }

    public void TestPrint1()
    {
        for (int num = 2; num < 100; num++)
        {
            bool isPrime = true;
            // 遍历2到num的平方根（取整），判断是否有因数
            for (int i = 2; i <= Math.Sqrt(num); i++)
            {
                if (num % i == 0)
                {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime)
            {
                Console.Write(num + " ");
            }
        } 
    }
}